Use the TryCatch Activity

Note: Use caution when building or editing a workflow. For further advice or to arrange training, contact your professional services consultant.

The TryCatch activity can be used to handle errors when an exception occurs within a workflow.

To add the TryCatch activity to a workflow:

  1. Click the Microsoft Toolbox tab in the Activity section of Workflow Builder.

  2. Select TryCatch from the Error Handling section.

    Microsoft toolbox TryCatch activity

  3. Drag and drop the TryCatch activity into the desired location within the Sequence panel.

    TryCatch activity in Sequence

    This activity contains the following properties:

    • DisplayName - the title of the activity

      Note: The DisplayName property is set to TryCatch by default.

    • Try - the activity that you want to execute when the TryCatch activity is executed
    • Catches - the catch element to check if the Try activity throws an exception
    • Finally - the activity that you want to execute on completion of the Try and Catches activities

  4. Drag the drop the desired activities into the Try section of the TryCatch activity.

    Activity added to the Try section of TryCatch

  5. Edit the properties of the included activity accordingly.
  6. Select from the Exception drop-down field. The following exceptions are available:

    • System.ArgumentException - alerts you to a problem within an argument
    • System.NullReferenceException - occurs when there is an attempt to dereference a null object reference
    • System.IO.IOException - alerts you when an I/O (input/output) error occurs
    • System.InvalidOperationException - advises of an invalid method call that is not caused by an invalid argument
    • System.Exception - the base class for all other exceptions, used to advise of all errors

    Exception drop-down

    Alternatively, select Browse for Types to display the Browse and Select a .Net Type window.

    Browse and Select a .Net Type window

    Note: Multiple catches can be added to the TryCatch activity.

  7. Select an exception, then click Ok.
  8. Drag the drop the desired activity into the Finally section.

    Activity added to the Finally section of TryCatch

  9. Edit the properties of the included activity as required.
  10. Click Save.

Back to top